package com.itheima.web;

import com.itheima.pojo.Student;
import com.itheima.service.StudentService;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @author Xiao
 * @date 2021/9/1
 */
@WebServlet("/deleteServlet")
public class DeleteServlet extends HttpServlet {
    private static StudentService studentService =new StudentService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String id = request.getParameter("id");
        studentService.delete(Integer.parseInt(id));
        request.getRequestDispatcher("/selectAllServlet").forward(request,response); //转发
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
